import java.util.ArrayList;
import java.util.Comparator;
import java.util.Objects;

class Card implements Comparable<Card>{
    public String suit;
    public int rank;

    public Card(String suit, int rank) {
        this.suit = suit;
        this.rank = rank;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Card card = (Card) o;
        return rank == card.rank && Objects.equals(suit, card.suit);
    }

    @Override
    public int hashCode() {
        return Objects.hash(suit, rank);
    }

    @Override
    public int compareTo(Card o) {
        return this.rank-o.rank;
    }

    @Override
    public String toString() {
        return "Card{" + "suit= " +suit +"/" +",rank= "+rank + "}";
    }
}

class SuitComparator implements Comparator<Card>{
    @Override
    public int compare(Card o1, Card o2) {
        return o1.suit.compareTo(o2.suit);
    }
}

public class Test2 {
    public static void main(String[] args) {
        ArrayList<Integer> list = new ArrayList<>();
        list.add(1);
        list.add(2);
        list.add(3);
        int[] array = {1,2,3,4};


        Card card1 = new Card("hongtao",15);
        Card card2 = new Card("heitao",5);
        if(card1.compareTo(card2) > 0) {
            System.out.println("card1 > card2");
        }else {
            System.out.println("card1 <= card2");
        }
        System.out.println("======");
        SuitComparator suitComparator = new SuitComparator();
        if(suitComparator.compare(card1,card2) > 0) {
            System.out.println("card1 > card2");
        }else {
            System.out.println("card1 <= card2");
        }
    }
    public static void main1(String[] args) {
        Card card1 = new Card("红桃",5);
        Card card2 = new Card("红桃",5);

        System.out.println(card1.equals(card2));

    }
}
